package Properties.T6;

import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class T6 {

    public static void main(String[] args) throws IOException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {

        Properties pro = new Properties();
        FileInputStream fis = new FileInputStream("data.properties");
        pro.load(fis);
        fis.close();

        Class<User> userClass = User.class;
        User user = userClass.newInstance();

        for (String s : pro.stringPropertyNames()) {
            String set = "set" + s.substring(0, 1).toUpperCase() + s.substring(1);
            Method method = userClass.getMethod(set,String.class);
            method.invoke(user,pro.getProperty(s));
        }

        System.out.println(user.toString());

    }
}